local beishui = fk.CreateSkill {
  name = "lingling__beishui",
}

Fk:loadTranslationTable{
  ["lingling__beishui"] = "背水",
  [":lingling__beishui"] = "当你受到伤害后，若你体力为1，你可以获得一张【杀】或【闪】。",
  ["#lingling__beishui"] = "背水：你可以获得一张【杀】或【闪】",
}

beishui:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(beishui.name) and player.hp == 1
  end,
  on_cost = function (self, event, target, player, data)
    local name = player.room:askToChoice(player,{
      choices = {"slash","jink","Cancel"},
      skill_name = beishui.name,
      prompt = "#lingling__beishui",
    })
    if name ~= "Cancel" then
      event:setCostData(self,name)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = room:getCardsFromPileByRule(event:getCostData(self))
    if #card > 0 then
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, beishui.name, nil, false, player)
    end
  end,
})

return beishui